/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.parts.date;

import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import researchgrants.parts.LoggedData.LoggedDataOutSerializable;
import researchgrants.parts.date.DateForDb;

/**
 *
 * @author DOStudent1
 */
public class LoggedDate extends Date implements LoggedDataOutSerializable  {

    public String toLoggedData() {
        return(DateForDb.fromDate(this).toDbString());
    }

    public LoggedDate(long date) {
        super(date);
    }

    public static LoggedDate fromLoggedData(String loggedString) {
        LoggedDate newLoggedDate=null;
        try {
            newLoggedDate=new LoggedDate(DateForDb.fromDbString(loggedString).toDate().getTime());
        } catch (ParseException ex) {
            Logger.getLogger(LoggedDate.class.getName()).log(Level.SEVERE, null, ex);
        }
        return(newLoggedDate);
    }

}
